package shoppingAnalysis;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class MyCombiner3 extends Reducer<Text, Text, Text, Text> {
	@Override
	protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
		// 对中间结果进一步合并后再发送给reduce ,减少网络数据的传输量
		int sum = 0;
		for (Text value : values) {
			sum += Integer.parseInt(value.toString());
		}
		// 输出
		context.write(key, new Text(String.valueOf(sum)));

	}
}
